package net.paruo.google.gwt.study_meeting.user_control.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;

public class MessageDialogBox extends Composite {

	private static MessageDialogBoxUiBinder uiBinder = GWT
			.create(MessageDialogBoxUiBinder.class);

	interface MessageDialogBoxUiBinder extends
			UiBinder<Widget, MessageDialogBox> {
	}

	@UiField
	DialogBox dialog;
	@UiField
	HTML message;
	@UiField
	Button btnClose;

	public MessageDialogBox(String title) {
		initWidget(uiBinder.createAndBindUi(this));
		dialog.setText(title);
		dialog.setAnimationEnabled(true);
	}

	public void center(String message) {
		this.message.setHTML(message);
		dialog.center();
	}

	@UiHandler("btnClose")
	void onClick(ClickEvent e) {
		dialog.hide();
	}

}
